package animal;

//动物类
public class Test {
    public static void main(String[] args) {
  //      Animal animal=new Animal("小动物");
//        Cat cat=new Cat("圆圆");
//        Bird bird=new Bird("鹦鹉");
//        fun(animal,"食物");
//        fun(cat,"猫粮");
//        fun(bird,"小虫");
//        animal.eat("吃的");
//        Cat cat=new Cat("喵喵");
//        cat.eat("猫粮");
//        Bird bird=new Bird("鹦鹉");
//        bird.eat("虫子");
//        bird.fly();
//        Animal animal=new Cat();
        Animal a1=new Animal("动物");
        a1.eat("谷子");
        Animal cat=new Cat("圆圆");
        cat.eat("谷子");
        Animal bird=new Bird("鹦鹉");
        bird.eat("谷子");
        if(bird instanceof Bird) {
            Bird bird1 = (Bird) bird;
            bird1.fly();
        }
        if(cat instanceof Bird){
            Bird bird2 = (Bird) bird;
            bird2.fly();
        }
    }
}
